HTTP Extension - HTTP Client

This notebook demonstrates the HTTP extension which introduces the %url and %%request commands.


In [1]:
%extension http

%url Command

The %url command allows constructing a URL request with query string, headers, or request data pulled from notebook variables.


In [2]:
%url --help


Usage: url <method> <url> [options]

method     the HTTP method to use (eg. GET, POST, etc.)
url        the URL to request

Options:
   --query variable     the name of the variable containing query data
   --headers variable   the name of the variable containing headers
   --data variable      the name of the variable containing request content
   --response mode      the response display mode (all, status, headers, metadata or body)  [all]

Issues the specified HTTP request and displays the resulting response.

In [3]:
%url get https://www.google.com/images/srpr/logo11w.png --response=body


%%request Command

The %%request command allows specifying a full HTTP request verbatim within the cell.


In [4]:
%%request --help


Usage: request [options]

Options:
   --response mode   the response display mode (all, status, headers, metadata or body)  [all]

Issues the specified HTTP request and displays the resulting response.

In [5]:
%%request
GET http://ip.jsontest.com/


HTTP 200 

access-control-allow-origin: *
content-type: application/json; charset=ISO-8859-1
date: Sun, 10 May 2015 13:09:23 GMT
server: Google Frontend
cache-control: private
alternate-protocol: 80:quic,p=1,80:quic,p=1
accept-ranges: none
vary: Accept-Encoding
transfer-encoding: chunked


In [6]:
%%request
POST http://headers.jsontest.com/
Foo: Bar

Sample request body


HTTP 200 

access-control-allow-origin: *
content-type: application/json; charset=ISO-8859-1
date: Sun, 10 May 2015 13:09:24 GMT
server: Google Frontend
cache-control: private
alternate-protocol: 80:quic,p=1,80:quic,p=1
accept-ranges: none
vary: Accept-Encoding
transfer-encoding: chunked


In [ ]: